<div class="top-content">

  <%#########################origin#############################%>
  <% if false %>
      <%= form_tag(:controller => 'open_source_projects', :action => "search", :method => :get) do %>
          <table width="940px">
            <tr>
              <td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_osp_community) %></td>
              <td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
              <td rowspan="2">
                <div class="project-search" style="float: right">
                  <%#= text_field_tag 'name', params[:name], :size => 30 %>
                  <%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
                  <%= render :partial => "search_bar" %>
                </div>
              </td>
            </tr>
            <tr>
              <td style="padding-left: 8px">
                <a><%= link_to request.host()+"/open_source_projects", :controller => 'open_source_projects', :action => 'index' %> </a>
              </td>
              <td><%= link_to l(:field_homepage), home_path %>
                > <%= link_to l(:label_osp_community), :controller => 'open_source_projects', :action => 'index' %></td>
            </tr>
          </table>
      <% end %>
  <% end %>
  <%#########################origin#############################%>
  <table style="width: 940px;">
    <tr>
      <td class="info_font" style="width: 240px; color: #15bccf"><%= l(:label_osp_community) %></td>
      <td style="width: 200px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
      <td rowspan="2">
        <div class="top-content-search" style="float: right;">
          <%#= form_tag(:controller => 'open_source_projects', :action => "search", :method => :get) do %>
          <%#= text_field_tag 'name', params[:name], :size => 20 %>
          <%#= hidden_field_tag 'project_type', params[:project_type] %>
          <%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
          <%# end %>
          <%= render :partial => "open_source_projects/search_bar" %>
        </div>
      </td>
    </tr>
    <tr>
      <td style="padding-left: 8px">
        <%= link_to request.host()+"/index", :controller => 'open_source_projects', :action => 'index' %>
      </td>
      <td><%= link_to l(:field_homepage), home_path %>
        >
        <%= link_to l(:label_osp_community), :controller => 'open_source_projects', :action => 'index' %>
      </td>
    </tr>
  </table>

</div>

<!-------------------------css----------------->
<%= javascript_include_tag "ichart.1.2.min" %>
<%= stylesheet_link_tag "buglist-div-use.css" %>
<%= stylesheet_link_tag "buglist-ichart.css" %>
<%= stylesheet_link_tag "buglist.css" %>

<div class="bug-module">
<% if !@bugs.nil? %>
    <div class="mask">
      <div class="header2"></div>
      <div class="colleft">
        <div class="col1">
          <h1><%= l(:label_safety_analysis) %> </h1>

          <div id='canvasDiv' style="border-style:none"></div>
        </div>

        <div class="col2">
          <div>
            <span> <h1 style="fontsize:19px">软件安全态势</h1></span><span style="margin-top: -30px; margin-right:70px;float: right; display: block;"><%= link_to '更多 >>', allbug_open_source_projects_path %></span>
          </div>
          <div class="fixed"></div>
          <div class="li_list" style="margin-top:10px;margin-left:10px">
            <ul style="list-style-type: square;">
              <% @bugs.each do |bug| %>
                  <li style="width:400px;"><span class="li_time">[<%= show_description_of_bug(bug) %>
                    ]</span><%= link_to bug.title, bug.url, :target => '_blank' %></li>
              <% end %>
            </ul>
          </div>
        </div>
      </div>
    </div>

    <div style="clear:both; margin:0 0 10 0">
      <script type="text/javascript">
          $(function () {
              var flow = [];
              for (var i = 0; i < 24 + 5; i++) {
                  flow.push(Math.floor(Math.random() * (30 + ((i % 12) * 5))) + 10);
                  // t.push(Math.floor(Math.random()*(30+((i%12)*5)))+10);
              }

              //gcm
              var sum = 0;
              for (var i = 0; i < flow.length; i++) {
                  sum = sum + flow[i];
              }
              //gcm end
              var data = [
                  {
                      name: '',
                      value: flow,
                      color: '#0d8ecf',
                      line_width: 2
                  }

              ];

//        for (var i = 0; i < 24 + 5; i++) {
//            data.push({name: '', value: flow[i], color: '#0d8ecf', line_width: 2});
//            // t.push(Math.floor(Math.random()*(30+((i%12)*5)))+10);
//        }

              //创建x轴标签文本
              var date = new Date()

              var labels = [];
              /* labels.push(date.getFullYear()-2);
               labels.push(date.getFullYear()-1);
               labels.push(date.getFullYear());*/

              labels = ["2012", "", "", "", "", "", "", "", "", "", "", "", "2013", "", "", "", "", "", "", "", "", "", "", "", "2014", "", "", "", ""];

              //var labels = ["","2010","2011","2012","2013","2014"];

              var chart = new iChart.LineBasic2D({
                  render: 'canvasDiv',
                  data: data,
                  align: 'center',
                  title: '',
                  subtitle: '',
                  footnote: '',
                  width: 430, // 面板大小
                  height: 210,
                  shadow: true,
                  //shadow_color : '#20262f',
                  shadow_blur: 1,
                  shadow_offsetx: 0,
                  shadow_offsety: 2,
                  //background_color:null //'#383e46'设置透明背景
                  animation: true,
                  animation_duration: 600,
                  animation_timing_function: 'ease-out',

                  tip: {
                      enable: true,
//                shadow: true,
//                shadow_offsetx: 0,
//                shadow_offsety: 0,
                      move_duration: 400,
                      border: {
                          enable: true,
                          radius: 5,
                          width: 2,
                          color: '#3f8695'
                      },
                      listeners: {
                          //tip:提示框对象、name:数据名称、value:数据值、text:当前文本、i:数据点的索引
                          parseText: function (tip, name, value, text, i) {
                              return "漏洞数:" + value;
                          }
                      }
                  },
                  tipMocker: function (tips, i) {
                      var index;
                      if (Math.floor(i / 12) == 0) {
                          index = 0;
                      } else if (Math.floor(i / 12) == 1) {
                          index = 12;
                      } else {
                          index = 24;
                      }
                      ;
                      return "<div style='font-weight:400'>" +
                              labels[index] + " " +//日期
                              ((i % 12) == 0 ? "1 月" : ((i % 12 + 1)) + "月") +  //时间
                              "</div>" + tips.join("<br/>");
                  },


//            legend: {
//                enable: true,
//                row: 1,//设置在一行上显示，与column配合使用
//                column: 'max',
//                valign: 'top',
//                sign: 'bar',
//                background_color: null,//设置透明背景
//                offsetx: -80,//设置x轴偏移，满足位置需要
//                border: true
//            },
                  crosshair: {
                      enable: true, //十字交叉线
                      line_color: '#62bce9'
                  },
                  sub_option: {
                      label: false, //是否显示数值
                      // hollow_inside:false,
                      smooth: true,//平滑曲线
                      point_size: 2 // 焦点大小
                      // point_hollow : true,


                  },

                  coordinate: {
                      width: 370, // 图表大小
                      //valid_width:330,
                      height: 150,
                      axis: {
                          // color:'#9f9f9f',
                          color: '#dcdcdc',
                          width: [0, 0, 2, 2]
                      },
                      grids: {
                          vertical: {
                              way: 'share_alike',
                              value: 1
                              // 改垂直线
                          }
                      },

                      scale: [
                          {
                              position: 'left',
                              start_scale: 0,
                              scale_space: 10,
                              end_scale: 100,
                              scale_color: '#9f9f9f'
                              // label : {color:'#ffffff',fontsize:11},

                          },
                          {
                              position: 'bottom',
                              labels: labels
                          }
                      ]
                  }
              });
              //开始画图

              /**
               *自定义组件,画平均线。
               */
              chart.plugin(new iChart.Custom({
                  drawFn: function () {
                      /**
                       *计算平均值的高度(坐标Y值)
                       *计算高度还不会！ 会划线了！
                       */
                      var avg = sum / 29,
                              coo = chart.getCoordinate(),
                              x = coo.get('originx'),
                              W = coo.width,
                              S = coo.getScale('left'),
                              H = coo.height,
                              h = (avg - S.start) * H / S.distance,
                              y = chart.y + H - h;

                      chart.target.line(x, y, x + W, y, 2, '#b32c0d')
                              .textAlign('start')
                              .textBaseline('middle')
                              .textFont('600 12px Verdana');
                  }
              }));
              chart.draw();
          });

          //]]>
      </script>
    </div>
<% end %>
</div>




<%= javascript_include_tag "jqcloud-1.0.4.js" %>
<%#= javascript_include_tag "jquery.js" %>
<%= stylesheet_link_tag "jqcloud.css" %>

<!-------------------tag cloud---------------------->
<!--<div class="tag-cloud" style="">-->
<!--<span class="title">-->
<!--<h1 style="margin-top:20px;fontsize:19px;color: #EE0000;font-weight:900">全球热门开源项目</h1>-->
<!--</span>-->

<!--<div class="tag-cloud-entity" style="margin-top:10px;width: 935px; height: 350px; border: 1px solid #ccc;"></div>-->
<!--</div>-->
<!------------------------tag-cloud------------------------>
<script type="text/javascript">

</script>




<%#======================================================================box before%>
<%#= render :partial => 'classified_search' %>
<% if false %>
<style type="text/css">
    .tb-navigation {
        position: relative;
        z-index: 400;
    }

        /*blockquote, body, button, code, dd, div, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, input, legend, li, ol, p, pre, td, textarea, th, ul {
            margin: 0;
            padding: 0;
        }*/

    .navigation {
        color: #666;
        border: 2px solid #d7d6d6;
    }

    .nav-switch {
        position: absolute;
        top: 0;
        right: 0;
        border-width: 14px;
        border-color: #bdbdbd #bdbdbd transparent transparent;
        border-style: solid solid dashed dashed;
        z-index: 10;
    }

    .navigation .nav-switch-icon {
        background-position: -266px 3px;
    }

    .navigation .icon-search, .navigation .nav-pill-cancle, .navigation .nav-switch-icon, .navigation .nav-topbar .topbar-search .topbar-submit, .navigation .nav-topbar-arror {
        /*background: url()*/
    }

    .nav-switch-icon {
        width: 15px;
        height: 15px;
        position: absolute;
        top: -13px;
        right: -13px;
        cursor: pointer;
    }

    .nav-topbar, .type-min {
        position: relative;
    }

    .nav-category-group {
        clear: both;
    }

    .nav-topbar {
        background-color: #f5f4f4;
        border-bottom: 1px solid #e4e4e4;
        z-index: 4;
    }

    .nav-topbar .nav-topbar-content {
        line-height: 36px;
        padding: 0 16px;
        overflow: hidden;
    }

    .nav-topbar-content {
        margin: 0 4px;
        white-space: nowrap;
    }

    ol, ul {
        list-style: none;
    }

    ul, menu, dir {
        display: block;
        list-style-type: disc;
        -webkit-margin-before: 1em;
        -webkit-margin-after: 1em;
        -webkit-margin-start: 0px;
        -webkit-margin-end: 0px;
        -webkit-padding-start: 40px;
    }

    .nav-topbar .nav-topbar-content {
        line-height: 36px;
    }

    li {
        margin-right: 7px;
        float: left;
    }

    .type-line {
        overflow: hidden;
    }

    .nav-category-group {
        clear: both;
    }

    .type-line .nav-category {
        clear: both;
        position: relative;
        padding: 0 100px 0 107px;
        height: 20px;
        overflow: hidden;
        margin-top: 11px;
        margin-bottom: 11px;
    }

    .nav-category h4 {
        position: absolute;
        color: #666;
        font-weight: 400;
        left: 22px;
        top: 0;
        overflow: hidden;
        max-width: 68px;
        white-space: nowrap;
        text-overflow: ellipsis;
        padding-right: 5px;
        text-align: left;
    }

    .nav-search-con {
        padding-top: 7px;
    }
</style>

<div class="">
  <div class="tb-navigation" data-spm="a230r.1.3" style="margin-top:20px">
    <div class="navigation">
      <div class="nav-switch">
        <a href="javascript:(function (){$('.nav-container').toggle();})();">
          <div class="nav-switch-icon J_Switch" trace="navHideButton" title="收起导航">
          </div>
        </a>
      </div>

      <div class="nav-container" style="">
        <div data-group="nav-topbar">
          <div class="nav-topbar-content">
            <ul>
              <li class="nav-search-con">查找条件><span class="nav-topbar-arror"></span>
              </li>
              <li>
                        	<span class="topbar-search J_TopbarSearch">

                                <%= show_condition(@app_dir, @language, @created_time, params[:name]) %>
                            </span>
              </li>
              <li class="nav-search-con">共 <span class="h"><%= @projects_count %></span> 个开源项目</li>
              <!-- <li class="related-count"><a href="/search?q=iphone&amp;app=vproduct&amp;vlist=1&amp;from_combo=true">8款相关产品</a></li> -->
            </ul>
          </div>
          <div class="nav-category-panel"></div>
        </div>
        <div class="nav-content">
          <!-- 推荐属性-->
          <div class="nav-category-group type-line" data-group="type-line">
            <div class="nav-category ">
              <h4 title="网络类型">应用方向<span>：</span></h4>
              <%= link_to "操作系统相关", search_open_source_projects_path(:app_dir => "操作系统相关", :language => @language, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "管理和监控", search_open_source_projects_path(:app_dir => "管理和监控", :language => @language, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "游戏/娱乐", search_open_source_projects_path(:app_dir => "游戏/娱乐", :language => @language, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "应用工具", search_open_source_projects_path(:app_dir => "应用工具", :language => @language, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "数据库相关", search_open_source_projects_path(:app_dir => "数据库相关", :language => @language, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "服务器软件", search_open_source_projects_path(:app_dir => "服务器软件", :language => @language, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "网站系统", search_open_source_projects_path(:app_dir => "网站系统", :language => @language, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "插件和扩展", search_open_source_projects_path(:app_dir => "插件和扩展", :language => @language, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <span class="arrow arrow-bottom"></span>
              </a>
            </div>
            <div class="nav-category ">
              <h4 title="网络类型">开发语言<span>：</span></h4>
              <%= link_to "JAVA", search_open_source_projects_path(:language => "JAVA", :app_dir => @app_dir, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "C++", search_open_source_projects_path(:language => "c++", :app_dir => @app_dir, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "C", search_open_source_projects_path(:language => "c", :app_dir => @app_dir, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "C#", search_open_source_projects_path(:language => "c#", :app_dir => @app_dir, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "ruby", search_open_source_projects_path(:language => "ruby", :app_dir => @app_dir, :created_time => @created_time, :name => params[:name]), :class => "nav-more J_More show" %>
              <%#= link_to "其他", open_source_projects_path(:language => "其他", :app_dir => @app_dir, :created_time => @created_time), :class => "nav-more J_More show" %>

              <span class="arrow arrow-bottom"></span>
              </a>
            </div>
            <div class="nav-category ">
              <h4 title="网络类型">创立时间<span>：</span></h4>
              <%= link_to "2014", search_open_source_projects_path(:app_dir => @app_dir, :language => @language, :created_time => "2014", :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "2013", search_open_source_projects_path(:app_dir => @app_dir, :language => @language, :created_time => "2013", :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "2012", search_open_source_projects_path(:app_dir => @app_dir, :language => @language, :created_time => "2012", :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "2011", search_open_source_projects_path(:app_dir => @app_dir, :language => @language, :created_time => "2011", :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "2010", search_open_source_projects_path(:app_dir => @app_dir, :language => @language, :created_time => "2010", :name => params[:name]), :class => "nav-more J_More show" %>
              <%= link_to "更早", search_open_source_projects_path(:app_dir => @app_dir, :language => @language, :created_time => "earlier", :name => params[:name]), :class => "nav-more J_More show" %>

              <span class="arrow arrow-bottom"></span>
              </a>
            </div>
          </div>
          <div class="nav-category-group type-block" data-group="type-block">
            <div class="nav-flexbox ">
            </div>
            <div class="nav-flexbox ">
            </div>
            <div class="nav-flexbox last">
              <div class="nav-category">
                <h4 title="上市时间"></h4>

                <div class="nav-category-wrap ">
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<%#======================================================================box after%>
<% end %>
<div id="projects-index">

  <ul class='projects'>
    <% for i in (0..@open_source_projects.size-1) %>
    	<% project = @open_source_projects[i] %>
            <li class='project-table'>
              <div class='root'>
                <%= link_to project.name, open_source_project_path(project), :class => "project root leaf", :onclick => "user_trace_click_project_in_project_list(this,#{i+1},'#{request.session_options[:id]}')" %>
                <span style="float: right;"></span>
                <%= render :partial => 'open_source_projects/os_project', :locals => {:project => project, :i => i} %>
              </div>
            </li>
    <% end %>
  </ul>
</div>

<div class="pagination">
  <ul>
    <%= pagination_links_full @projects_pages, @projects_count %>
  </ul>
</div>

<% html_title(l(:label_project_plural)) -%>

<!-- ajax user trace zhangxunhui begin -->
<script type="text/javascript">
	function user_trace_click_project_in_project_list(e,rank,session_id){
		//获取ids
		content = $(e).attr("href"); //获取id url
		id = content.substring(22); //要跳过第一个 /open_source_projects/123 第22个字符到最后
		//获取URL中的id
		page = '<%= @projects_pages.page %>';
    	$.ajax({
			contentType: "application/json; charset=utf-8",
			timeout: 5000,
			url: '/user_traces/click_project_in_project_list?page=' + page + "&rank=" + rank + "&id=" + id + "&session_id=" + session_id,
			dataType: "json"
		});
	}
</script>
<!-- ajax user trace zhangxunhui end -->

<!-- ajax user trace zhangxunhui begin -->
<script type="text/javascript">
	function click_project_img_in_project_list(e,session_id,rank){
		content = $(e).attr("href"); //获取id url
		osp_id = content.substring(22); //要跳过第一个 /open_source_projects/123 第22个字符到最后
		//获取URL中的id
		page = '<%= @projects_pages.page %>';
    	$.ajax({
			contentType: "application/json; charset=utf-8",
			timeout: 5000,
			url: '/user_traces/click_project_img_in_project_list?page=' + page + "&rank=" + rank + "&osp_id=" + osp_id + "&session_id=" + session_id,
			dataType: "json"
		});
    }
</script>
<!-- ajax user trace zhangxunhui end -->
